home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / mach / sun4c.md / fpu_simulator.h < prev    next >
C/C++ Source or Header  |  1989-08-17  |  5KB  |  190 lines

  1. /*    @(#)fpu_simulator.h 1.8 88/02/08 SMI    */
  2.  
  3. /*
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  */
  6.  
  7. /*
  8.  * This whole file refuses to lint.
  9.  */
  10. #ifndef lint
  11.     /*    Sparc floating-point simulator PUBLIC include file. */
  12.  
  13. #include <sun4/reg.h>
  14. #include <sys/ieeefp.h>
  15.  
  16.     /*    PUBLIC TYPES    */
  17.  
  18. enum fcc_type        /* relationships */
  19.     {
  20.     fcc_equal    = 0,
  21.     fcc_less    = 1,
  22.     fcc_greater    = 2,
  23.     fcc_unordered    = 3
  24.     } ;
  25.  
  26.     /* FSR types. */
  27.  
  28. enum ftt_type        /* types of traps */
  29.     {
  30.     ftt_none    = 0,
  31.     ftt_ieee    = 1,
  32.     ftt_unfinished    = 2,
  33.     ftt_unimplemented = 3,
  34.     ftt_sequence    = 4,
  35.     ftt_alignment    = 5,    /* defined by software convention only */
  36.     ftt_fault    = 6,    /* defined by software convention only */
  37.     ftt_7        = 7
  38.     } ;
  39.  
  40. typedef            /* Sparc FSR. */
  41.     struct
  42.     {
  43.     enum fp_direction_type        rd :    2 ; /* rounding direction */
  44.     enum fp_precision_type        rp :    2 ; /* rounding precision */
  45.     unsigned            tem:    5 ; /* trap enable mask */
  46.     unsigned            :    6 ;
  47.     enum ftt_type            ftt :    3 ; /* FPU trap type */
  48.     unsigned            qne :    1 ; /* FPQ not empty */
  49.     unsigned            pr :    1 ; /* partial result */
  50.     enum fcc_type            fcc :    2 ; /* FPU condition code */
  51.     unsigned            aexc:    5 ; /* accumulated exception */
  52.     unsigned            cexc:    5 ; /* current exception */
  53.     }
  54.     fsr_type ;
  55.  
  56. typedef            /* FPU register viewed as single components. */
  57.     struct
  58.     {
  59.     unsigned sign :         1 ;
  60.     unsigned exponent :     8 ;
  61.     unsigned significand :    23 ;
  62.     }
  63.     single_type ;
  64.  
  65. typedef            /* FPU register viewed as double components. */
  66.     struct
  67.     {
  68.     unsigned sign :         1 ;
  69.     unsigned exponent :    11 ;
  70.     unsigned significand :    20 ;
  71.     }
  72.     double_type ;
  73.  
  74. typedef            /* FPU register viewed as extended components. */
  75.     struct
  76.     {
  77.     unsigned sign :         1 ;
  78.     unsigned exponent :    15 ;
  79.     unsigned unused :    16 ;
  80.     }
  81.     extended_type ;
  82.  
  83. typedef            /* FPU register with multiple data views. */
  84.     union
  85.     {
  86.     int        int_reg ;
  87.     long        long_reg ;
  88.     unsigned    unsigned_reg ;
  89.     float        float_reg ;
  90.     single_type    single_reg ;
  91.     double_type    double_reg ;
  92.     extended_type    extended_reg ;
  93.     }
  94.     freg_type ;
  95.  
  96. enum fp_op_type        /* Type specifiers in FPU instructions. */
  97.     {
  98.     fp_op_integer    = 0,    /* Not in hardware, but convenient to define. */
  99.     fp_op_single    = 1,
  100.     fp_op_double    = 2,
  101.     fp_op_extended    = 3
  102.     } ;
  103.  
  104. enum fp_opcode        /* FPU op codes, minus precision and leading 0. */
  105.     {
  106.     fmovs        = 0x0,
  107.     fnegs        = 0x1,
  108.     fabss        = 0x2,
  109.     fp_op_3 = 3, fp_op_4 = 4, fp_op_5 = 5, fp_op_6 = 6, fp_op_7 = 7,
  110.     fp_op_8        = 0x8,
  111.     fp_op_9        = 0x9,
  112.     fsqrt        = 0xa,
  113.     fp_op_b = 0xb, fp_op_c = 0xc, fp_op_d = 0xd,
  114.     fp_op_e = 0xe, fp_op_f = 0xf,
  115.     fadd        = 0x10,
  116.     fsub        = 0x11,
  117.     fmul        = 0x12,
  118.     fdiv        = 0x13,
  119.     fcmp        = 0x14,
  120.     fcmpe        = 0x15,
  121.     fp_op_16 = 0x16, fp_op_17 = 0x17,
  122.     fp_op_18    = 0x18,
  123.     fp_op_19    = 0x19,
  124.     fp_op_20    = 0x20,
  125.     fp_op_21    = 0x21,
  126.     fp_op_22    = 0x22,
  127.     fp_op_23    = 0x23,
  128.     fp_op_24 = 0x24, fp_op_25 = 0x25, fp_op_26 = 0x26, fp_op_27 = 0x27,
  129.     fp_op_28 = 0x28, fp_op_29 = 0x29, fp_op_2a = 0x2a, fp_op_2b = 0x2b,
  130.     fp_op_2c = 0x2c, fp_op_2d = 0x2d, fp_op_2e = 0x2e, fp_op_2f = 0x2f,
  131.     fp_op_30    = 0x30,
  132.     ftos        = 0x31,
  133.     ftod        = 0x32,
  134.     ftox        = 0x33,
  135.     ftoi        = 0x34,
  136.     fp_op_35 = 0x35, fp_op_36 = 0x36, fp_op_37 = 0x37,
  137.     ft_op_38    = 0x38,
  138.     fp_op_39 = 0x39, fp_op_3a = 0x3a, fp_op_3b = 0x3b,
  139.     fp_op_3c    = 0x3c,
  140.     fp_op_3d = 0x3d, fp_op_3e = 0x3e, fp_op_3f = 0x3f
  141.     } ;
  142.  
  143. typedef            /* FPU instruction. */
  144.     struct
  145.     {
  146.     unsigned        hibits    : 2 ;    /* Top two bits. */
  147.     unsigned        rd    : 5 ;    /* Destination. */
  148.     unsigned        op3    : 6 ;    /* Main op code. */
  149.     unsigned        rs1    : 5 ;    /* First operand. */
  150.     unsigned        ibit    : 1 ;    /* I format bit. */
  151.     enum fp_opcode        opcode    : 6 ;    /* Floating-point op code. */
  152.     enum fp_op_type        prec    : 2 ;    /* Precision. */
  153.     unsigned        rs2    : 5 ;    /* Second operand. */
  154.     }
  155.     fp_inst_type ;
  156.  
  157.     /* PUBLIC FUNCTIONS */
  158.  
  159. extern enum ftt_type
  160. fpu_simulator( /* pinst, pfsr */ ) ;
  161. /*    fp_inst_type    *pinst;    /* Pointer to FPU instruction to simulate. */
  162. /*    fsr_type    *pfsr;    /* Pointer to image of FSR to read and write. */
  163.  
  164. /*
  165.  * fpu_simulator simulates FPU instructions only; reads and writes FPU data
  166.  * registers directly.
  167.  */
  168.  
  169. extern enum ftt_type
  170. fp_emulator( /* pinst, pregs, pwindow, pfpu */ ) ;
  171. /*    fp_inst_type    *pinst;    /* Pointer to FPU instruction to simulate. */
  172. /*    struct regs    *pregs;    /* Pointer to PCB image of registers. */
  173. /*    struct window    *pwindow;/* Pointer to locals and ins. */
  174. /*    struct fpu    *pfpu;    /* Pointer to FPU register block. */
  175.  
  176. /*
  177.  * fp_emulator simulates FPU and CPU-FPU instructions; reads and writes FPU
  178.  * data registers from image in pfpu.
  179.  */
  180.  
  181. extern void
  182. fp_traps( /*ftt, rp */) ;
  183. /*    enum ftt_type    ftt;    /* Type of trap. */
  184. /*    struct regs    *rp;    /* Pointer to PCB image of registers. */
  185. /*
  186.  * fp_traps handles passing execption conditions to the kernel.
  187.  * It is called after fp_simulator or fp_emulator fail (return a non-zero ftt).
  188.  */
  189. #endif /* lint */
  190.